import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Dialog {
    id: formDialog
    title: "用户信息"
    modal: true
    standardButtons: Dialog.Save | Dialog.Cancel

    property string username: nameField.text
    property string email: emailField.text
    property string birthDate: birthDateField.text

    GridLayout {
        anchors.fill: parent
        columns: 2
        columnSpacing: 10
        rowSpacing: 10

        Label {
            text: "姓名:"
        }
        TextField {
            id: nameField
            Layout.fillWidth: true
            placeholderText: "请输入姓名"
        }

        Label {
            text: "邮箱:"
        }
        TextField {
            id: emailField
            Layout.fillWidth: true
            placeholderText: "请输入邮箱"
            validator: RegularExpressionValidator {
                regularExpression: /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
            }
        }

        Label {
            text: "出生日期:"
        }
        TextField {
            id: birthDateField
            Layout.fillWidth: true
            placeholderText: "YYYY-MM-DD"
            validator: RegularExpressionValidator {
                regularExpression: /^\d{4}-\d{2}-\d{2}$/
            }
        }
    }

    onAccepted: {
        console.log("保存用户信息:")
        console.log("姓名:", username)
        console.log("邮箱:", email)
        console.log("出生日期:", birthDate)
    }
} 